﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using BioBookWcf;

namespace BioBookHost3
{
    public class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Console Based WCF Host");
            using (ServiceHost serviceHost = new ServiceHost(typeof(BioBookService)))
            {

                serviceHost.Open();
                Console.WriteLine("The service is ready.");
                Console.WriteLine("Press the Enter key to terminate service.");

                DisplayHostInfo(serviceHost);
                Console.ReadLine();
                serviceHost.Close();


            }
        }

        static void DisplayHostInfo(ServiceHost host)
        {
            Console.WriteLine();
            Console.WriteLine("***** Host Info *****");
            foreach (System.ServiceModel.Description.ServiceEndpoint se
            in host.Description.Endpoints)
            {
                Console.WriteLine("Address: {0}", se.Address);
                Console.WriteLine("Binding: {0}", se.Binding.Name);
                Console.WriteLine("Contract: {0}", se.Contract.Name);
                Console.WriteLine();
            }
            Console.WriteLine("**********************");
        }
    }
}
